package com.example.class1;

import android.os.Handler;
import android.util.Log;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MyTask implements Runnable {
     private static final String TAG="MyTask";
     private Handler handler;

     public void setHandler(android.os.Handler handler){
         this.handler=handler;
     }

    @Override
    public void run() {
        try {
            Thread.sleep ( 3000);
        } catch ( InterruptedException e ) {
            e.printStackTrace();
        }



            List< String > retList = new ArrayList< String >();
        try {
                Document doc = Jsoup. connect ( " https://www.boc.cn/sourcedb/whpj/ ").get();
                String title = doc . title ();
                Log.i(TAG ,"run: title ="+ title );
                Elements trs = doc . getElementsByTag ( " tr "); for ( Element tr : trs ) {
                Elements tds = tr.getElementsByTag("td ");
                Log.i(TAG, " run : td . size =" + tds.size());
                if (tds.size() > 0) {
                    String td1 = tds.get(0).text();
                    String td2 = tds.get(5).text();
                    Log.i(TAG, " run :" + td1 + "==>" + td2);
                    retList.add(td1 + "==>" + td2);

                }


            }
} catch (IOException e) {
            e.printStackTrace();
        }
        }



}

